package constants

import (
	"hi-jvm/instructions/util"
	"hi-jvm/rtda"
)

// 从字节码中获取一个byte型整数，扩展成int，推入栈顶 指令码：0x10
type BIPUSH struct {
	val int8
}

// 从字节码中获取一个short型整数， 推入栈顶 指令码：0x11
type SIPUSH struct {
	val int16
}

func (self *BIPUSH) FetchOperands(reader *util.BytecodeReader) {
	self.val = reader.ReadInt8()
}

func (self *BIPUSH) Execute(frame *rtda.Frame) {
	i := int32(self.val)
	frame.OperandStack.PushInt(i)
}


func (self *SIPUSH) FetchOperands(reader *util.BytecodeReader) {
	self.val = reader.ReadInt16()
}

func (self *SIPUSH) Execute(frame *rtda.Frame) {
	i := int32(self.val)
	frame.OperandStack.PushInt(i)
}